<?php
namespace doujunyu\utility\ali;

use AlipayConfig;
use AlipayFundAuthOrderAppFreezeRequest;
use AlipayFundAuthOrderUnfreezeRequest;
use AlipayOpenAppQrcodeCreateRequest;
use AlipaySystemOauthTokenRequest;
use AlipayTradePagePayRequest;
use AlipayUserCertdocCertverifyPreconsultRequest;
use AlipayUserCertdocCertverifyConsultRequest;
use AopClient;
use DatadigitalFincloudGeneralsaasFaceCertifyInitializeRequest;
use DatadigitalFincloudGeneralsaasFaceCertifyQueryRequest;
use DatadigitalFincloudGeneralsaasFaceCertifyVerifyRequest;
use DatadigitalFincloudGeneralsaasMobilethreemetaSimpleCheckRequest;
use AlipayTradePayRequest;
use AlipayUserDeloauthDetailQueryRequest;
use DatadigitalFincloudGeneralsaasMobilethreemetaDetailCheckRequest;
// require '../extend/Pay/AliPay/sdk/aop/AopClient.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/AopClient.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/AopCertClient.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/AopCertification.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/AlipayConfig.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipaySystemOauthTokenRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayOpenAppQrcodeCreateRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayUserCertdocCertverifyPreconsultRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayUserCertdocCertverifyConsultRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/DatadigitalFincloudGeneralsaasMobilethreemetaSimpleCheckRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayFundAuthOrderAppFreezeRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/DatadigitalFincloudGeneralsaasFaceCertifyInitializeRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/DatadigitalFincloudGeneralsaasFaceCertifyQueryRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/DatadigitalFincloudGeneralsaasFaceCertifyVerifyRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayTradePayRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayFundAuthOrderUnfreezeRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/AlipayUserDeloauthDetailQueryRequest.php';
require_once  dirname(__FILE__).'/alipaysdk/v2/aop/request/DatadigitalFincloudGeneralsaasMobilethreemetaDetailCheckRequest.php';



class AliOuth{
    private $app_id = "appid";
    private $merchant_private_key = "秘钥";
    private $notify_url = "http://外网可访问网关地址/alipay.trade.page.pay-PHP-UTF-8/notify_url.php";
    private $return_url = "http://外网可访问网关地址/alipay.trade.page.pay-PHP-UTF-8/return_url.php";
    private $charset = "UTF-8";
    private $sign_type = "RSA2";
    private $gatewayUrl = "https://openapi.alipay.com/gateway.do";
    // private $gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";//沙箱模式
    private $alipay_public_key = "支付宝公钥";

    private $alipayConfig = null;

    public function __construct($app_id,$merchant_private_key,$alipay_public_key,$notify_url = '',$return_url = '') {
        $this->app_id = $app_id;//应用ID,您的APPID。
        $this->merchant_private_key = $merchant_private_key;//商户私钥
        $this->notify_url = $notify_url;//异步通知地址
        $this->return_url = $return_url;//同步跳转
        $this->alipay_public_key = $alipay_public_key;//支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。

        $privateKey  = $this->merchant_private_key;
        $alipayPublicKey = $this->alipay_public_key;
        $alipayConfig = new AlipayConfig();
        $alipayConfig->setServerUrl($this->gatewayUrl);
        $alipayConfig->setAppId($this->app_id);
        $alipayConfig->setPrivateKey($privateKey);
        $alipayConfig->setFormat('json');
        $alipayConfig->setAlipayPublicKey($alipayPublicKey);
        $alipayConfig->setCharset('UTF-8');
        $alipayConfig->setSignType('RSA2');
        $this->alipayConfig = $alipayConfig;

    }

    /**用户登录授权
     * https://opendocs.alipay.com/mini/84bc7352_alipay.system.oauth.token?scene=common&pathHash=c6cfe1ef
     * @param string $code 授权码
     * @param string $grant_type 授权方式
     * @param string $refresh_token 刷新令牌
     */
    public function login_token($code = '',$grant_type = 'authorization_code', $refresh_token = ''){
        // 初始化SDK
        $alipayClient = new AopClient($this->alipayConfig);
        // 构造请求参数以调用接口AlipaySystemOauthTokenRequest
        $request = new AlipaySystemOauthTokenRequest();
        $model = array();
        if($refresh_token){
            // 设置刷新令牌
            $request->setRefreshToken($refresh_token);
        }
        // 设置授权码
        if($code){
            $request->setCode($code);
        }
        // 设置授权方式
        $request->setGrantType($grant_type);
        // 如果需要返回GET请求，请使用
        $pageRedirectionData = $alipayClient->execute($request, "GET");
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $pageRedirectionData->$responseApiName;
        if(!$response->open_id){
            return ['授权失败',''];
        }
        $d = [
            'access_token' => $response->access_token,
            'auth_start' => $response->auth_start,
            'expires_in' => $response->expires_in,
            'open_id' => $response->open_id,
            're_expires_in' => $response->re_expires_in,
            'refresh_token' => $response->refresh_token,
        ];
        return ['',$d];
        
        
    }


    /**获取手机号后解密方式
     * https://opendocs.alipay.com/common/02mse3
     * @param string $aesKey AES密钥
     * @param string $content 密文
     */
    public static function openSign($aesKey,$content) {        
        // $aesKey="MB4I9*****";
        //AES密钥
        // $content="Ho5y3nixH0tSnYWw8p/HMTO1bIONKSYd7BfkbI+ww4qgJEXKMYFWnSwjXN2B9YwvsKBYykK2gva2v1jfnQVSNQ==";        
        $result=openssl_decrypt(base64_decode($content), 'AES-128-CBC', base64_decode($aesKey),OPENSSL_RAW_DATA);        
        $v = json_decode($result, true);        
        if(!isset($v) && !isset($v['code'])){
            return ['支付宝返回错误',''];
        }
        if($v['code'] !== '10000'){
            return ['支付宝'.$v['subMsg'],''];
        }
        return ['',$v['mobile']];  
    } 
    
    /**获取二维码
     * https://opendocs.alipay.com/mini/a25c5d8f_alipay.open.app.qrcode.create?scene=common&pathHash=2334bbff
     * @param string $url_param 跳转小程序的页面路径
     * @param string $query_param 跳转小程序的页面参数
     * @param string $describe 码描述
     * @param string $color 颜色
     * @param string $size 合成后图片的大小
     */
    public function qrcode_create($url_param,$query_param,$describe,$color = '',$size = ''){
        // 初始化SDK
        $alipayClient = new AopClient($this->alipayConfig);
        // 构造请求参数以调用接口AlipaySystemOauthTokenRequest
        $request = new AlipayOpenAppQrcodeCreateRequest();
        $model = array();
        // 设置跳转小程序的页面路径
        $model['url_param'] = $url_param;//"page/component/component-pages/view/view"
        // 设置小程序的启动参数
        $model['query_param'] = $query_param;//"x=1"
        // 设置码描述
        $model['describe'] = $describe;//"码描述"
        //颜色
        if($color){
            $model['color'] = $color;//"码颜色"
        }
        //合成后图片的大小
        if($size){
            $model['size'] = $size;//"二维码描述"
        }
        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request, null, "", null);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',[
                'qr_code_url' => $response->qr_code_url,
                'qr_code_url_circle_white' => $response->qr_code_url_circle_white,
                'qr_code_url_circle_blue' => $response->qr_code_url_circle_blue,
            ]];
        }
        else{
            return [$response->msg,[]];
        }
    }

    // +---------------------------------------------------
    // + 实名认证
    // +---------------------------------------------------

    /**实名证件信息比对验证预咨询
     * https://opendocs.alipay.com/apis/api_2/alipay.user.certdoc.certverify.preconsult
     */
    public function certverify_preconsult($params=[]){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new AlipayUserCertdocCertverifyPreconsultRequest();
        $request->setBizContent(json_encode($params,JSON_UNESCAPED_UNICODE));
        $result = $alipayClient->execute( $request); 
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['',['verify_id' => $result->$responseNode->verify_id]];
        } else {
            return [$result->$responseNode->sub_msg,[]];
        }

    }

    
    /**实名证件信息比对验证咨询
     * https://opendocs.alipay.com/open/02qq4r?pathHash=e1ceb96b
     */
    public function certverify_consult($accessToken,$params=[]){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new AlipayUserCertdocCertverifyConsultRequest();
        $request->setBizContent(json_encode($params,JSON_UNESCAPED_UNICODE));
        $result = $alipayClient->execute( $request,$accessToken); 
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['',$result->$responseNode];
        } else {
            return [$result->$responseNode->sub_msg,[]];
        }

    }

    // +---------------------------------------------------
    // + 人脸认证
    // +---------------------------------------------------
    /**手机号三要素核验简版
     * https://opendocs.alipay.com/open/b53bf66d_datadigital.fincloud.generalsaas.mobilethreemeta.simple.check?pathHash=c46d2ca2
     */
    public function certify_initialize($outer_biz_no,$cert_name,$cert_no,$phone){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new DatadigitalFincloudGeneralsaasMobilethreemetaSimpleCheckRequest();
        $model = array();

        // 设置外部订单号
        $model['outer_biz_no'] = $outer_biz_no;

        // 设置姓名
        $model['cert_name'] = $cert_name;

        // 设置证件号码
        $model['cert_no'] = $cert_no;

        // 设置手机号
        $model['phone'] = $phone;

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',[
                'certify_id' => $response->certify_id,
                'match' => $response->match,
                'isp' => $response->isp,
                'detail' => $response->detail,
            ]];
        }
        else{
            return [$response->sub_msg,[]];
        }
    }
    /**手机号三要素核验详版
     * https://opendocs.alipay.com/open/b53bf66d_datadigital.fincloud.generalsaas.mobilethreemeta.simple.check?pathHash=c46d2ca2
     */
    public function mobilethreemeta_detail_check($outer_biz_no,$cert_name,$cert_no,$phone){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new DatadigitalFincloudGeneralsaasMobilethreemetaDetailCheckRequest();
        $model = array();

        // 设置外部订单号
        $model['outer_biz_no'] = $outer_biz_no;

        // 设置姓名
        $model['cert_name'] = $cert_name;

        // 设置证件号码
        $model['cert_no'] = $cert_no;

        // 设置手机号
        $model['phone'] = $phone;

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',[
                'certify_id' => $response->certify_id,
                'match' => $response->match,
                'isp' => $response->isp,
                'detail' => $response->detail,
            ]];
        }
        else{
            return [$response->sub_msg,[]];
        }
    }
    /**人脸核身第一步
     * https://opendocs.alipay.com/open/7a5e3e37_datadigital.fincloud.generalsaas.face.certify.initialize?scene=common&pathHash=b2519840
     */
    public function face_certify_initialize($outer_order_no,$cert_name,$cert_no,$return_url = ''){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new DatadigitalFincloudGeneralsaasFaceCertifyInitializeRequest();
        $model = array();

        // 设置商户请求的唯一标识
        $model['outer_order_no'] = $outer_order_no;

        // 设置H5人脸核身场景码
        $model['biz_code'] = "FUTURE_TECH_BIZ_FACE_SDK";

        // 设置认证信息
        $identityParam = array();
        $identityParam['cert_type'] = "IDENTITY_CARD";
        $identityParam['cert_name'] = $cert_name;
        $identityParam['cert_no'] = $cert_no;
        $identityParam['identity_type'] = "CERT_INFO";
        $model['identity_param'] = $identityParam;

        // 设置商户配置信息
        $merchantConfig = array();
        $merchantConfig['face_reserve_strategy'] = "reserve";
        $merchantConfig['return_url'] = $return_url;
        $model['merchant_config'] = $merchantConfig;

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',[
                'certify_id' => $response->certify_id,
            ]];
        }
        else{
            return [$response->sub_msg,[]];
        }
    }
    /**人脸核身第一步（通过第一步返回的certify_url）
     * https://opendocs.alipay.com/open/7a5e3e37_datadigital.fincloud.generalsaas.face.certify.initialize?scene=common&pathHash=b2519840
     */
    public function face_certify_initialize_by_url($certify_id){ 
        $alipayClient = new AopClient($this->alipayConfig);
        // 构造请求参数以调用接口
        $request = new DatadigitalFincloudGeneralsaasFaceCertifyVerifyRequest();
        $model = array();

        // 设置本次申请操作的唯一标识
        $model['certify_id'] = $certify_id;

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return [[],[
                'certify_url' => $response->certify_url,
            ]];
        }
        else{
            return [$response->sub_msg,[]];
        }

    }
    /**人脸核身第二步，检查结果
     * https://opendocs.alipay.com/open/7a5e3e37_datadigital.fincloud.generalsaas.face.certify.initialize?scene=common&pathHash=b2519840
     */
    public function face_certify_query($certify_id){
        $alipayClient = new AopClient($this->alipayConfig);
        // 构造请求参数以调用接口
        $request = new DatadigitalFincloudGeneralsaasFaceCertifyQueryRequest();
        $model = array();

        // 设置本次申请操作的唯一标识
        $model['certify_id'] = $certify_id;

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',[
                'passed' => $response->passed,//T=通过，F=不通过
                'msg' => $response->msg
            ]];
        }
        else{
            return [$response->sub_msg,[]];
        }
    }


    // +---------------------------------------------------
    // + 信用产品-》芝麻免押
    // +---------------------------------------------------

    /**常见免押订单接口
     * https://opendocs.alipay.com/open/e2e70da4_alipay.fund.auth.order.app.freeze?scene=3392871eb88945fa977f613f214ea1c6&pathHash=1002681c
     */
    public function exempt_add($order_number,$order_title,$price,$day){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new AlipayFundAuthOrderAppFreezeRequest();
        $model = array();
        // 设置订单标题
        $model['order_title'] = $order_title;

        // 设置商户授权资金订单号
        $model['out_order_no'] = $order_number;

        // 设置商户本次资金操作的请求流水号
        $model['out_request_no'] = $order_number;

        // 设置需要冻结的金额
        $model['amount'] = $price;//"0.01";

        // 设置预授权订单相对超时时间
        $model['timeout_express'] = "2d";

        // 设置销售产品码
        $model['product_code'] = "PRE_AUTH_ONLINE";

        // 设置业务扩展参数
        $model['extra_param'] = "{\"category\": \"RENT_OFFICE_ELECTRIC\",\"serviceId\": \"2025101800000000000117868500\"}";

        // 设置免押受理台模式
        $model['deposit_product_mode'] = "DEPOSIT_ONLY";
        $request->setNotifyUrl($this->notify_url);
        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $orderStr = $alipayClient->sdkExecute($request);
        return $orderStr;
    }

    //免押扣款
    public function exempt_deduct($auth_no,$order_deduct_number,$price,$subject){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new AlipayTradePayRequest();
        $model = array();

        // 设置商户订单号
        $model['out_trade_no'] = $order_deduct_number;

        // 设置订单总金额
        $model['total_amount'] = $price;

        // 设置订单标题
        $model['subject'] = $subject;

        // 设置产品码
        $model['product_code'] = "PREAUTH_PAY";

        // 设置资金预授权单号
        $model['auth_no'] = $auth_no;

        // 设置预授权确认模式
        $model['auth_confirm_mode'] = "NOT_COMPLETE";

        // 设置订单包含的商品列表信息
        // $goodsDetail = array();
        // $goodsDetail0 = array();
        // $goodsDetail0['goods_name'] = "xx车辆租金";
        // $goodsDetail0['quantity'] = 1;
        // $goodsDetail0['price'] = "2000";
        // $goodsDetail0['goods_id'] = "xxrent_car0001";
        // $goodsDetail0['goods_category'] = "34543238";
        // $goodsDetail0['categories_tree'] = "124868003|126232002|126252004";
        // $goodsDetail0['show_url'] = "http://www.alipay.com/xxx.jpg";
        // $goodsDetail[] = $goodsDetail0;
        // $model['goods_detail'] = $goodsDetail;

        // 设置业务扩展参数
        // $extendParams = array();
        // $extendParams['sys_service_provider_id'] = "2088511833207846";
        // $extendParams['specified_seller_name'] = "XXX的租车商户";
        // $extendParams['card_type'] = "S0JP0000";
        // $model['extend_params'] = $extendParams;

        // 设置优惠明细参数
        $promoParams = array();
        $promoParams['actual_order_time'] = date('Y-m-d H:i:s');
        $model['promo_params'] = $promoParams;

        // 设置商户门店编号
        // $model['store_id'] = "NJ_001";

        // 设置商户机具终端编号
        // $model['terminal_id'] = "NJ_T_001";

        // 设置返回参数选项
        $queryOptions = array();
        $queryOptions[] = "fund_bill_list";
        $model['query_options'] = $queryOptions;
        $request->setNotifyUrl($this->notify_url);
        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',[]];
        }
        else{
            return [$response->sub_msg,[]];
        }

    }

    //
    /**完结
     * https://opendocs.alipay.com/open/77d39a7a_alipay.fund.auth.order.unfreeze?scene=common&pathHash=38132584
     * 完结接口
     * @param $auth_no
     * @param $out_request_no
     * @param $price
     * @param $subject
     * @return array
     * @throws Exception
     */
    public function exempt_finish($auth_no,$out_request_no,$price,$subject){
        $alipayClient = new AopClient($this->alipayConfig);
        // 构造请求参数以调用接口
        $request = new AlipayFundAuthOrderUnfreezeRequest();
        $model = array();

        // 设置支付宝资金授权订单号
        $model['auth_no'] = $auth_no;

        // 设置解冻请求流水号
        $model['out_request_no'] = $out_request_no;

        // 设置本次操作解冻的金额
        $model['amount'] = "$price";

        // 设置商户对本次解冻操作的附言描述
        $model['remark'] = $subject;

        // 设置解冻扩展信息
        $model['extra_param'] = json_encode([
            'unfreezeBizInfo' => true
        ],JSON_UNESCAPED_UNICODE);
        $request->setNotifyUrl($this->notify_url);
        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        // 如果是第三方代调用模式，请设置app_auth_token（应用授权令牌）
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            if($response->status !== "SUCCESS"){
                return [$response->msg,[]];
            }
            return ['',[$response]];
        }
        else{
            return [$response->code.$response->sub_msg,[]];
        }

        // 订单支付时传入的商户订单号,和支付宝交易号不能同时为空。 trade_no,out_trade_no如果同时存在优先取trade_no
    }

    // +---------------------------------------------------
    // + 其他
    // +---------------------------------------------------
    /**查询解除授权明细
     * https://opendocs.alipay.com/apis/0afpr5
     */
    public function alipay_user_deloauth_detail_query($data, $page = 1,$limit = 10 ){
        $alipayClient = new AopClient($this->alipayConfig);
        $request = new AlipayUserDeloauthDetailQueryRequest();
        $model = array();
        $model = array();

        // 设置查询的日期
        $model['date'] = $data ?? date('Ymd');

        // 设置偏移位置
        $model['offset'] = $page;

        // 设置查询数量
        $model['limit'] = $limit;

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            return ['',$response];
        }
        else{
            return [$response->code.$response->sub_msg,[]];
            
        }
    }




}
















